import { CubeTextureLoader } from "../../thirdparty/three/imports";
import { CubeTexture3D } from "../textures/CubeTexture3D";

export class CubeTextureLoader3D
{
    _cubeTextureLoader = new CubeTextureLoader();

    setPath(path: string)
    {
        this._cubeTextureLoader.setPath(path);

        return this;
    }

    load(urls: string[], onLoad?: (texture: CubeTexture3D) => void, onProgress?: (event: ProgressEvent<EventTarget>) => void, onError?: (event: ErrorEvent) => void)
    {
        const texture = this._cubeTextureLoader.load(urls, (texture) =>
        {
            const texture3D = CubeTexture3D.get(texture);
            if (onLoad)
            {
                onLoad(texture3D);
            }
        }, onProgress, onError);

        const texture3D = CubeTexture3D.get(texture);

        return texture3D;
    }
}
